import service from '@/utils/request'

// 首页分类列表
export const getGoodsList = (category, limit) => {
  return service({
    url: `goods/list/?category=${category}&limit=${limit}`,
    method: 'get'
  })
}

// 添加购物车
export const addCart = data => {
  return service({
    url: 'cart',
    method: 'post',
    data
  })
}

// 获取购物车列表
export const infoCart = data => {
  return service({
    url: 'cart/' + 1,
    method: 'get',
    data
  })
}

// 全部商品列表
export const allListCart = () => {
  return service({
    url: 'category',
    method: 'get'
  })
}

// 商品详情
export const detaail = (goodsid) => {
  return service({
    url: '/goods/skus/' + goodsid,
    method: 'get'
  })
}

// 用户评论
export const reviewData = (goodsid) => {
  return service({
    url: 'goods/item/' + goodsid,
    method: 'get'
  })
}

// 下订单
export const addOrder = data => {
  return service({
    url: '/order',
    method: 'post',
    data
  })
}
// 获取订单列表
export const getOrder = () => {
  return service({
    url: '/order',
    method: 'get'
  })
}

// 删除购物车商品
export const delCart = data => {
  return service({
    url: '/cart/delete',
    method: 'post',
    data
  })
}

// 删除购物车商品
export const Cancelanorder = data => {
  return service({
    url: '/order/delete',
    method: 'post',
    data
  })
}
